
import router from '@/router'
export function get_organization_list(store) {
  store.dispatch('user/get_organization_list').then(res => {
    console.log('res', res)
    let store_list = res.data
    if (store_list.length === 1) {
      let storeData = store_list[0]
      let parentOrganizationCode = storeData.parentOrganizationCode || storeData.organizationCode
      let parentOrganizationName = storeData.parentOrganizationName || storeData.organizationName
      delete storeData.parentOrganizationCode
      delete storeData.parentOrganizationName
      store.commit(
        'user/SET_ORGANIZATION_INFO',
        { ...storeData, parentOrganizationCode, parentOrganizationName }
      )
      // store.commit('chatUser/SET_USER_ID', storeData.organizationCode)
      // store.dispatch('chatUser/logout')
      router.push('/')
    } else {
      router.push('/organization')
    }
  })
}
